<%--
  Created by IntelliJ IDEA.
  User: Specter
  Date: 2019/5/5
  Time: 13:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="User.UserInfo" %>
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登录界面</title>

    <!-- Site Properties -->
    <link rel="stylesheet" type="text/css" th:href="@{/webjars/Semantic-UI/2.3.3/semantic.min.css}" href="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/semantic.css">
    <link rel="stylesheet" th:href="@{/css/login.css}" href="/css/login.css">

</head>

<body>
<jsp:useBean id="u" class="User.UserInfo"/>
<%
String TJusername=request.getParameter("username");
String TJpassword=request.getParameter("password");
if(TJpassword!=null&&TJusername!=null){
if(u.CheckLogin(TJusername,TJpassword)){
    u.setUsername(TJusername);
    u.setPassword(TJpassword);
    u=u.Login(TJusername,TJpassword);
    HttpSession session1=request.getSession(true);
    session1.setAttribute("UserInfo",u);
    response.sendRedirect("message.jsp");
}
%><script>alert("用户名不存在或密码错误！")</script><%
        }
%>
<div class="ui middle aligned center aligned grid">
    <div class="column">
        <h2 class="ui image header" style="color: white">
            绿色生活——用户登录
        </h2>
        <div class="ui segment circle-0 mb-0" style="opacity: 0.8">

            <div class="ui tab account active" data-tab="account">
                <form class="ui large form" action="Login.jsp" method="post">
                    <div class="ui stacked">
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="user circle outline icon"></i>
                                <input class="circle-0" type="text" name="username" placeholder="用户名" autofocus>
                            </div>
                        </div>
                        <div class="field">
                            <div class="ui left icon input">
                                <i class="lock icon"></i>
                                <input class="circle-0" type="password" name="password" placeholder="密码">
                            </div>
                        </div>
                        <div class="flex-between" style="margin-bottom: 1rem;">
                            <div class="ui checkbox">
                                <input type="checkbox" name="remember" tabindex="0" class="hidden">
                                <label>记住我</label>
                            </div>
                            <a href="javascript: void(0);" class="forget-pass">忘记密码</a>
                        </div>
                        <input class="ui fluid large teal submit button circle-0" type="submit" value="登录">
                    </div>
                    <div class="ui error mini message"></div>

                </form>
            </div>

        </div>

        <div class="ui message mt-0 flex-between circle-0 other-way" style="opacity:0.8">
            <div style="display: flex;">
                <span class="muted">其他登录方式：</span>
                <a class="icon mr-1" th:href="@{/oauth2/authorization/dgut}" href="/login/dgut" title="东莞理工学院登录">
                    <img th:src="@{/images/dgut.png}" src="/css/dgut.png">
                </a>
            </div>
            <a class="sign" href="register.jsp" >立即注册</a>
        </div>
    </div>
</div>

<script th:src="@{/webjars/jquery/3.3.1/jquery.min.js}" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script th:src="@{/webjars/Semantic-UI/2.3.3/components/tab.min.js}" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/components/tab.min.js"></script>
<script th:src="@{/webjars/Semantic-UI/2.3.3/components/form.min.js}" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/components/form.min.js"></script>
<script th:src="@{/webjars/Semantic-UI/2.3.3/components/checkbox.min.js}" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/components/checkbox.min.js"></script>
<script th:src="@{/webjars/Semantic-UI/2.3.3/components/transition.min.js}" src="https://cdnjs.cloudflare.com/ajax/libs/semantic-ui/2.3.3/components/transition.min.js"></script>


<script>
    $(function () {
        $('.account .ui.form').form({
            fields: {
                email: {
                    identifier: 'username',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入用户名'
                    }]
                },
                password: {
                    identifier: 'password',
                    rules: [{
                        type: 'empty',
                        prompt: '请输入密码'
                    }]
                }
            }
        });
        $('.menu .item').tab();
        $('.ui.checkbox').checkbox();
    });

</script>

</body>
</html>